import pandas as pd
import matplotlib.pyplot as plt
import numpy as np
import re

BlueList = ['#92B4F4', '#7772CA', '#5E7CE2', '#C6CDFF', '#248BD6', '#0F6BAE']

time_1 = [101, 99,  50, 50,  49, 48]
time_2 = [122, 118, 60, 60,  56, 60]
time_3 = [114, 111, 56, 109, 55, 108]

new_time_1 = [x/60 for x in time_1]
new_time_2 = [x/60 for x in time_2]
new_time_3 = [x/60 for x in time_3]

fig, axes = plt.subplots(1, 1, figsize=(20,8))
font_size = 28
plt.xticks(fontsize=font_size)
plt.yticks(fontsize=font_size)
plt.grid()
plt.ylabel("FPS", fontsize=font_size+4)

pos1 = [1,5,9,13,17,21]
pos2 = [2,6,10,14,18,22]
pos3 = [3,7,11,15,19,23]

labels = ["RealSense", "Yolo C1", "Yolo C2", "Arm C1", "Arm C2", "Judge"]
plt.xticks(pos2, labels=labels, size=font_size)

bar1 = axes.bar(pos1, new_time_1, edgecolor='black', color=BlueList[2], label='ROS 2')
bar2 = axes.bar(pos2, new_time_2, edgecolor='black', color=BlueList[1], label='RoboSpike (No PGO)')
bar3 = axes.bar(pos3, new_time_3, edgecolor='black', color=BlueList[0], label='RoboSpike')

for i in range(6):
    plt.text(pos1[i], new_time_1[i], ' {:.2f}'.format(new_time_1[i]), rotation=90, va="bottom", ha="center", fontsize=font_size - 4)
    plt.text(pos2[i], new_time_2[i], ' {:.2f}'.format(new_time_2[i]), rotation=90, va="bottom", ha="center", fontsize=font_size - 4)
    plt.text(pos3[i], new_time_3[i], ' {:.2f}'.format(new_time_3[i]), rotation=90, va="bottom", ha="center", fontsize=font_size - 4)

axes.spines['top'].set_visible(False)
axes.spines['right'].set_visible(False)

plt.legend(loc=4, prop={'size': font_size-4})
plt.savefig("./figures/sys/sys.png", bbox_inches='tight')